package utils;

import irio.gamer.gamer;

import java.awt.Color;
import java.awt.GridLayout;
import java.awt.TextField;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.NumberFormat;

import javax.swing.BorderFactory;
import javax.swing.JComboBox;
import javax.swing.JFormattedTextField;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSlider;
import javax.swing.JTextField;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;

public class JMyCombo extends JPanel{

	public Vec vec = null;
	public JComboBox combo = null;
	public double[] values = null;
	
	public boolean postprocessing = false;
	
	
	public JMyCombo(String name, Vec v, String[] strings, double[] vals) {
		Create(name,v,strings,vals);
	}

	public JMyCombo(String name, Vec v, String[] strings, double[] vals, String s) {
		Create(name,v,strings,vals);
		setToolTipText(s);
	}
public void Create(String name, Vec v, String[] strings, double[] vals) {
		vec = v;
		values = vals;
		setLayout(new GridLayout(1,2));
		//setBorder(BorderFactory.createLineBorder(Color.gray));
		add(new JLabel(name));
		combo = new JComboBox(strings);
		add(combo);
		
		int idx = 0;
		for (int i=0;i<vals.length;i++)
			if (vals[i]==vec.x)
				idx = i;
		
		combo.setSelectedIndex(idx);
		
        combo.addActionListener(new ActionListener()
        {
//            @Override
            public void actionPerformed(ActionEvent event)
            {
               //When the fruit of veg button is pressed
               //the setVisible value of the listPanel and
               //comboPanel is switched from true to 
               //value or vice versa.
            	vec.x = values[combo.getSelectedIndex()];
            	gamer.imagePanel.preview.resetPreview(postprocessing);
            }
        });

	}
	
	
}
